package com.health.core.aspect;

import com.health.core.annotation.HealthAop;
import com.health.core.support.HealthThreadLocal;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

// 封装了aop的注入默认拦截的是HealthAop 大伙如果有aop相关的操作可以直接在这里添加HealthAop
// 后续可以是否可以实现在配置中操作 这个模块是多模块是公共模块如果定义切面的模式要慎重
@EnableAutoConfiguration
@Aspect
//@ConditionalOnProperty(name = "health.aspect.enabled", matchIfMissing = true)
public class HealthAspect {

    private Logger logger = LoggerFactory.getLogger(HealthAspect.class);

    @Before(value = "@annotation(healthVerify)")
    public void before(JoinPoint joinPoint , HealthAop healthVerify){
        joinPoint.getSignature();
        logger.info("aop拦截方法：{},数据源key:{}",joinPoint.getSignature().getDeclaringTypeName()+"-"+joinPoint.getSignature().getName(), HealthThreadLocal.getDataSourceKey());
    }




}
